package com.dgut.softproject.controller;


import com.dgut.softproject.util.Base64Utils;
import com.dgut.softproject.util.FastDFSClientWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class MerchandController {

    @Autowired
    private FastDFSClientWrapper fastDFSClient;

    //商家添加商品
    @PostMapping("/add")
    @ResponseBody
    public boolean add(String merchandPictureUrl){

        byte[] bytes = Base64Utils.decode(merchandPictureUrl);
        fastDFSClient.uploadFile(bytes, bytes.length, "jpg");
        return true;
    }

}
